home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / vol15n11.zip / TBWIZ.ZIP / TBSAVE~1.FRM < prev    next >
Text File  |  1996-02-09  |  9KB  |  310 lines

  1. VERSION 4.00
  2. Begin VB.Form tbSaveForm 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Save Toolbar"
  5.    ClientHeight    =   1590
  6.    ClientLeft      =   2850
  7.    ClientTop       =   3315
  8.    ClientWidth     =   4515
  9.    ControlBox      =   0   'False
  10.    Height          =   1995
  11.    Left            =   2790
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   1590
  16.    ScaleWidth      =   4515
  17.    ShowInTaskbar   =   0   'False
  18.    Top             =   2970
  19.    Width           =   4635
  20.    Begin VB.CommandButton Command2 
  21.       Caption         =   "Cancel"
  22.       Height          =   270
  23.       Left            =   3480
  24.       TabIndex        =   6
  25.       Top             =   720
  26.       Width           =   975
  27.    End
  28.    Begin VB.CommandButton Command1 
  29.       Caption         =   "&Save"
  30.       Height          =   270
  31.       Left            =   3480
  32.       TabIndex        =   5
  33.       Top             =   240
  34.       Width           =   975
  35.    End
  36.    Begin VB.Frame Frame1 
  37.       Caption         =   "Select controls:"
  38.       Height          =   1335
  39.       Left            =   120
  40.       TabIndex        =   0
  41.       Top             =   120
  42.       Width           =   3135
  43.       Begin VB.ComboBox Combo1 
  44.          Height          =   315
  45.          Index           =   1
  46.          Left            =   1065
  47.          TabIndex        =   4
  48.          Text            =   "Combo1"
  49.          Top             =   840
  50.          Width           =   1815
  51.       End
  52.       Begin VB.ComboBox Combo1 
  53.          Height          =   315
  54.          Index           =   0
  55.          Left            =   1065
  56.          TabIndex        =   2
  57.          Text            =   "Combo1"
  58.          Top             =   360
  59.          Width           =   1815
  60.       End
  61.       Begin VB.Label Label1 
  62.          AutoSize        =   -1  'True
  63.          Caption         =   "ImageList:"
  64.          Height          =   195
  65.          Index           =   1
  66.          Left            =   240
  67.          TabIndex        =   3
  68.          Top             =   860
  69.          Width           =   720
  70.       End
  71.       Begin VB.Label Label1 
  72.          AutoSize        =   -1  'True
  73.          Caption         =   "Toolbar:"
  74.          Height          =   195
  75.          Index           =   0
  76.          Left            =   360
  77.          TabIndex        =   1
  78.          Top             =   390
  79.          Width           =   585
  80.       End
  81.    End
  82.    Begin MSComDlg.CommonDialog CommonDialog1 
  83.       Left            =   3720
  84.       Top             =   1080
  85.       _Version        =   65536
  86.       _ExtentX        =   847
  87.       _ExtentY        =   847
  88.       _StockProps     =   0
  89.       CancelError     =   -1  'True
  90.       DefaultExt      =   "*.tbr"
  91.       DialogTitle     =   "Save Toolbar"
  92.       Filter          =   "*.tbr | Toolbars"
  93.    End
  94. End
  95. Attribute VB_Name = "tbSaveForm"
  96. Attribute VB_Creatable = False
  97. Attribute VB_Exposed = False
  98. Option Explicit
  99. DefInt A-Z
  100.  
  101. Function SaveTB() As Integer
  102. '*** ACTIVE PROJECT INFO
  103. 'Dim ProjectFilename$, ProjectDirty As Boolean
  104. 'ProjectFilename$ = gobjIDEAppInst.ActiveProject.FileName
  105. 'ProjectDirty = gobjIDEAppInst.ActiveProject.IsDirty
  106. 'Debug.Print ProjectFilename$
  107. 'Debug.Print ProjectDirty
  108.  
  109. '*** ACTIVE FORM INFO
  110. '****ACTIVE FORM NAME (FORM2)
  111. 'gobjIDEAppInst.ActiveProject.ActiveForm.Properties.Item("Name")
  112. '****ACTIVE FORM file count
  113. 'gobjIDEAppInst.ActiveProject.Components.Item(ssc%).FileCount
  114. '****Names of ACTIVE FORM files
  115.  'gobjIDEAppInst.ActiveProject.Components.Item(ssc%).FileNames(ssfiles%)
  116.  
  117. 'Dim ss As Object, ssc%, ssfiles%
  118. 'Set ss = gobjIDEAppInst.ActiveProject.Components
  119. 'For ssc% = 0 To ss.Count - 1
  120. '    If ss.Item(ssc%).Name = gobjIDEAppInst.ActiveProject.ActiveForm.Properties.Item("Name") Then'
  121. '        For ssfiles% = 0 To ss.Item(ssc%).FileCount - 1
  122. '            Debug.Print ss.Item(ssc%).FileNames(ssfiles%)
  123. '        Next
  124. '    End If
  125. 'Next
  126. 'setup
  127. Dim ProjectFilename$, ProjectDirty As Boolean
  128. Dim CurrFormName$, CurrFormFiles$(1)
  129. Dim i%, ii%
  130. Dim success As Boolean
  131. 'get project info
  132. 'ProjectFilename$ = gobjIDEAppInst.ActiveProject.FileName
  133. 'ProjectDirty = gobjIDEAppInst.ActiveProject.IsDirty
  134.  
  135. 'get form info
  136. With gobjIDEAppInst.ActiveProject
  137.     CurrFormName$ = .ActiveForm.Properties.Item("Name")
  138.     With .Components
  139.         For i% = 0 To .Count - 1
  140.             If .Item(i%).Name = CurrFormName$ Then
  141.                 CurrFormFiles$(0) = .Item(i%).FileNames(0)
  142.                 CurrFormFiles$(1) = .Item(i%).FileNames(1)
  143. '                Debug.Print CurrFormFiles$(0)
  144. '                Debug.Print CurrFormFiles$(1)
  145.             End If
  146.         Next
  147.     End With
  148. End With
  149. If CurrFormFiles$(0) = "" Or (Len(CurrFormFiles$(0)) = 0) Then
  150.     Alert "Save form file first!"
  151.     SaveTB = -1
  152.     Exit Function
  153. End If
  154.  
  155.  
  156. On Error Resume Next
  157. CommonDialog1.ShowSave
  158. If Err = cdlCancel Then SaveTB = 0: Exit Function
  159. On Error GoTo 0
  160. gfnameTBFile = CommonDialog1.FileName
  161. Screen.MousePointer = HOURGLASS
  162.  
  163. 'MsgBox ExtractFileRoot(gfnameTBFile)
  164. 'how about saveas to a temp
  165. 'then kill the temp
  166. Dim Source$
  167. Source$ = CurrFormFiles$(0)
  168.  
  169.  
  170.  
  171. Dim linetest$
  172. Dim Targ$
  173. Dim tbEvent$
  174. Dim icTest$, tbTest$
  175. Dim Terminator$
  176. icTest$ = "ImageList " & Combo1(1)
  177. tbTest$ = "Toolbar " & Combo1(0)
  178. tbEvent$ = Combo1(0) & "_"
  179. 'copy code to tbr file
  180. Targ$ = ExtractFilePath$(gfnameTBFile) + ExtractFileRoot(gfnameTBFile) + ".tbr"
  181. Terminator$ = "End"
  182. Open Targ$ For Output As #1    ' Open file for output.
  183. Open Source$ For Input As #2
  184.     Do While Not EOF(2)
  185.         Line Input #2, linetest$
  186.         If (InStr(linetest$, icTest$) > 0) Or (InStr(linetest$, tbTest$) > 0) Then
  187.             Print #1, linetest$
  188.             Do
  189.               Line Input #2, linetest$
  190.               Print #1, linetest$
  191.             Loop Until Trim$(linetest$) = Terminator$
  192.          End If
  193.      Loop
  194. Close #2
  195. 'now let's get the events
  196. Terminator$ = "End Sub"
  197. Print #1, "TB_EVENTS"
  198. Open Source$ For Input As #2
  199.     Do While Not EOF(2)
  200.         Line Input #2, linetest$
  201.         If InStr(linetest$, tbEvent$) > 0 Then 'toolbar event
  202.             Print #1, linetest$
  203.             Do
  204.               Line Input #2, linetest$
  205.               Print #1, linetest$
  206.             Loop Until Trim$(linetest$) = Terminator$
  207.         End If
  208.     Loop
  209. Close #2
  210. Close #1
  211.  
  212. 'Copy frx file
  213. Targ$ = ExtractFilePath$(gfnameTBFile) + ExtractFileRoot(gfnameTBFile) + ".frx"
  214. FileCopy ExtractFilePath$(Source$) + ExtractFileRoot(Source$) + ".frx", Targ$
  215. 'gfnameTBFilef
  216. SaveTB = 1
  217. Exit Function
  218.                      '**** REMOVE A FORM
  219.         
  220. '    Debug.Print .RemoveComponent(MyForm, True)
  221. '    Debug.Print .AddFile(CurrFormFiles$(0))
  222. '    With .Components
  223. '        For i% = 0 To .Count - 1
  224. '            If .Item(i%).Name = CurrFormName$ Then
  225. '                Debug.Print "reloading..."
  226. '                .Item(i%).Reload
  227. '            End If
  228. '        Next
  229. '    End With
  230.                 
  231.                 '**** RELOAD A FORM
  232. '                  .Item(i%).Reload
  233. 'can't remove and reload
  234. 'so can't take advantage of saving w/removing when reloading unless...remove/add then make changes then reload
  235.  
  236.         
  237. '        *** ADD A FORM
  238. '        Debug.Print .AddFile(CurrFormFiles$(0))
  239. 'End With
  240.  
  241.  
  242.  
  243.  
  244. 'Exit Sub
  245. Dim testControl As Object, MyControl As Object, MyProperty As Object
  246. Dim j%
  247.   
  248. For i = 0 To gobjIDEAppInst.ActiveProject.ActiveForm.ControlTemplates.Count - 1
  249.         'Debug.Print VBInstance.ActiveProject.ActiveForm.ControlTemplates(i)
  250.         Set testControl = gobjIDEAppInst.ActiveProject.ActiveForm.ControlTemplates(i)
  251.         If testControl.Properties.Item("Name") = "Toolbar1" Then
  252.             For j = 0 To testControl.Properties.Count - 1
  253.             Set MyProperty = testControl.Properties(j)
  254. '                Debug.Print "  Name: "; MyProperty.Name
  255. '                Debug.Print "  Type: "; MyProperty.Type
  256. '                Debug.Print "  Value: "; TypeName(MyProperty.Value)
  257. '            Debug.Print MyProperty.Value
  258.             Next j
  259.         End If
  260.             Set MyProperty